import React from 'react';
import { Button, Modal, Table } from 'antd';

class RelatedModal extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: false,
      list: [],
      loading: false
    }
  }

  openModal = () => {
    this.setState({ visible: true })
  }

  cancelModal = () => {
    this.setState({ visible: false })
  }

  componentDidMount() {
    if (this.props.onRef) {
      this.props.onRef(this);
    }
  }

  render() {
    const { visible, list, loading } = this.state;
    const columns = [
      {
        title: '标准问',
        dataIndex: 'basicQuestion',
        width: '70%'
      },
      {
        title: '操作',
        width: '20%',
        render: (text, row) => {
          return <Button type={'link'}>同步</Button>
        }
      }
    ];

    return (
      <Modal visible={visible} title={'关联问题'} footer={null} onCancel={this.cancelModal}>
        <Table columns={columns} dataSource={list} loading={loading} />
      </Modal>
    );
  }
}

export default RelatedModal;
